package com.example.weather.city_manager;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.weather.R;

import java.util.List;

public class DeleteCityAdapter extends BaseAdapter {
    Context context;
    List<String> mDatas;
    List<String>deleteCitys;
    private LayoutInflater inflater;
    public DeleteCityAdapter(Context context, List<String> mDatas,List<String>deleteCitys) {
        this.context = context;
        this.mDatas = mDatas;
        this.deleteCitys=deleteCitys;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int i) {
        return mDatas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        DeleteCityAdapter.ViewHolder holder = null;
        View convertView = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_deletecity,null);
            holder = new DeleteCityAdapter.ViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder = (DeleteCityAdapter.ViewHolder) convertView.getTag();
        }
        String bean = mDatas.get(i);
        holder.cityTv.setText(bean);
        return convertView;
    }
    class ViewHolder{
        TextView cityTv,conTv,currentTempTv,windTv,tempRangeTv;
        ImageView iv;
        public ViewHolder(View itemView){
            iv=itemView.findViewById(R.id.item_delete_iv);
            cityTv = itemView.findViewById(R.id.item_delete_tv);
        }
    }

}
